package com.star.jersey.mybatisplus.base.core.contract;

import java.util.List;

public class PageParam<Q> {
    protected long page = 1L;
    protected long limit = 10L;
    protected Q param;
    protected List<SortParam> sorts;

    public PageParam(long page, long limit) {
        if (page > 1L) {
            this.page = page;
        }

        if (limit > 0L) {
            this.limit = limit;
        }

    }

    public long getStartIndex() {
        return (this.page - 1L) * this.limit;
    }

    public long getEndIndex() {
        return this.getStartIndex() + this.limit;
    }

    public long getPage() {
        return this.page;
    }

    public long getLimit() {
        return this.limit;
    }

    public Q getParam() {
        return this.param;
    }

    public List<SortParam> getSorts() {
        return this.sorts;
    }

    public void setPage(long page) {
        this.page = page;
    }

    public void setLimit(long limit) {
        this.limit = limit;
    }

    public void setParam(Q param) {
        this.param = param;
    }

    public void setSorts(List<SortParam> sorts) {
        this.sorts = sorts;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof PageParam)) {
            return false;
        } else {
            PageParam<?> other = (PageParam)o;
            if (!other.canEqual(this)) {
                return false;
            } else if (!super.equals(o)) {
                return false;
            } else if (this.getPage() != other.getPage()) {
                return false;
            } else if (this.getLimit() != other.getLimit()) {
                return false;
            } else {
                Object this$param = this.getParam();
                Object other$param = other.getParam();
                if (this$param == null) {
                    if (other$param != null) {
                        return false;
                    }
                } else if (!this$param.equals(other$param)) {
                    return false;
                }

                Object this$sorts = this.getSorts();
                Object other$sorts = other.getSorts();
                if (this$sorts == null) {
                    if (other$sorts != null) {
                        return false;
                    }
                } else if (!this$sorts.equals(other$sorts)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof PageParam;
    }

    public int hashCode() {
        int result = super.hashCode();
        long $page = this.getPage();
        result = result * 59 + (int)($page >>> 32 ^ $page);
        long $limit = this.getLimit();
        result = result * 59 + (int)($limit >>> 32 ^ $limit);
        Object $param = this.getParam();
        result = result * 59 + ($param == null ? 43 : $param.hashCode());
        Object $sorts = this.getSorts();
        result = result * 59 + ($sorts == null ? 43 : $sorts.hashCode());
        return result;
    }

    public PageParam() {
    }

    public PageParam(long page, long limit, Q param, List<SortParam> sorts) {
        this.page = page;
        this.limit = limit;
        this.param = param;
        this.sorts = sorts;
    }

    public String toString() {
        return "PageParam(super=" + super.toString() + ", page=" + this.getPage() + ", limit=" + this.getLimit() + ", param=" + this.getParam() + ", sorts=" + this.getSorts() + ")";
    }
}
